package com.trace.meat.controller;

import com.trace.meat.entity.TestOnly;
import com.trace.meat.entity.TypeTbl;
import com.trace.meat.service.TypeTblService;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * (TypeTbl)表控制层
 *
 * @author makejava
 * @since 2021-06-19 12:08:17
 */
@RestController
@RequestMapping("typeTbl")
public class TypeTblController {
    /**
     * 服务对象
     */
    @Resource
    private TypeTblService typeTblService;

    /**
     * 通过主键查询单条数据
     *
     * @param tid 主键
     * @return 单条数据
     */
    @GetMapping("selectOne")
    public TypeTbl selectOne(Integer tid) {
        return this.typeTblService.queryById(tid);
    }
    /**
     * 新增数据
     */
    //http://127.0.0.1:11451/typeTbl/insertOne?tid=5&name=sda
    @GetMapping("insertOne")
    public TypeTbl insert(String name) {
        TypeTbl typeTbl=new TypeTbl();
        typeTbl.setName(name);
        return this.typeTblService.insert(typeTbl);
    }
    /**
     * 更新数据
     *
     */
    //http://127.0.0.1:11451/typeTbl/updateOne?tid=5&name=hjk
    @GetMapping("updateOne")
    public TypeTbl update(Integer tid, String name) {
        TypeTbl typeTbl=new TypeTbl();
        typeTbl.setTid(tid);
        typeTbl.setName(name);
        return typeTblService.update(typeTbl);
    }
    /**
     * 删除数据
     */
    //http://127.0.0.1:11451/typeTbl/deleteOne?tid=5
    @GetMapping("deleteOne")
    public boolean deleteById(Integer tid) {
        return typeTblService.deleteById(tid);
    }
}
